|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectvectorimage.VectorObject
raar.world.RAWorldObject
raar.world.RAWorldObjectMovable
raar.agent.RAAgent
raar.external.RAExternalAgent
public class RAExternalAgent
This class models all external agent designs. Adds to the normal RAAgent some
capacities with which external agents can be controlled. An external agent is
an agent that can also be run outside of SB-MASE, for example physical robots
or links to other programs. What basically happens is that SB-MASE reads the
sensor values indicated by the external sensors, executes the processes o.t.
agent normally, then reads and transfers the actor values back to the extern
agent. Communication is modelled with a socket, so that agents can be con-
trolled both locally and on a remote system. The communication language used
is described in the class RAExternalAgentProtocol.
On the server side of the socket the SBMServer accepts the messages
sent by the external agent (as long as there is a server running, obviously).
This server has been started with a specific robot model (specified by the
ExternalAgentInterface) and just reads sensor values from and writes actor
values to this model. In the model, all sensors have a unique id, so that we
know which sensor in SB-MASE is which sensor here. Read more on writing your
robot models elsewhere - it is quite simple.
When writing your own external agent, all you need to adapt here's the sensor
configuration. The external agent therefore must be constructed with sensor
config specified in an RAExternalSensor array. This sensor config can not be
changed afterwards. Make sure that the sensor id's of the RAExternalSensors
match those of the robot model you are using on the server, otherwise the
communication between the two parts will screw up.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface raar.external.RAExternalAgentProtocol |
|---|
RAExternalAgentProtocol.ERROR, RAExternalAgentProtocol.PANIC |
| Field Summary |
|---|
| Fields inherited from class raar.agent.RAAgent |
|---|
AGENT_CLASS_NAME, SIZE |
| Fields inherited from class raar.world.RAWorldObject |
|---|
SOBJ_AGENT, SOBJ_TRACE |
| Fields inherited from class vectorimage.VectorObject |
|---|
OBJ_ELLIPSE, OBJ_LINE, OBJ_RECTANGLE |
| Fields inherited from interface raar.external.RAExternalAgentProtocol |
|---|
AGENT_GO, CONNECT_AGENT, DISCONNECT_AGENT, GET_SENSORS, OK, SHUTDOWN_SERVER |
| Constructor Summary | |
|---|---|
RAExternalAgent(RAExternalSensor[] sensorConfig)
Construct an agent with the sensors specified. |
|
RAExternalAgent(RAExternalSensor[] sensorConfig,
boolean createActors)
Construct an agent with the sensors specified. |
|
| Method Summary | |
|---|---|
void |
addProcess(RAProcess p)
OVERRIDDEN METHOD, SO THAT SENSOR SETUP IS FIXED |
boolean |
canBeExternal()
Return whether SB-MASE can use this agent as an external one. |
boolean |
canBeSimulated()
Return whether SB-MASE can simulate this agent. |
void |
cancelConnect()
Cancel connect operation (has no timeout!) |
void |
connect(java.lang.String hostH,
int portP)
Connect the agent to a server at host and port given. |
void |
disconnect()
Disconnect. |
java.lang.String |
getHost()
Return host we're connected to. |
int |
getPort()
Return port we're connected to. |
RADataType |
getSensorValue(RAExternalSensor sensor)
RUNTIME EXTRA STUFF |
boolean |
isConnected()
Return whether this agent is externally connected. |
void |
messageReceived(java.lang.Object msg)
Receive a message. |
void |
pauseAgent()
Pause agent. |
void |
removeProcess(RAProcess p)
OVERRIDDEN METHOD, SO THAT SENSOR SETUP IS FIXED |
void |
replaceProcess(RAProcess p,
RAProcess newP)
OVERRIDDEN METHOD, SO THAT SENSOR SETUP IS FIXED |
void |
runAgent()
RUNNING THE AGENT IS SLIGHTLY DIFFERENT |
void |
runAgent(boolean simulated)
RUNNING THE AGENT IS SLIGHTLY DIFFERENT |
void |
sendMessage(java.lang.String message)
Send a message to the robotserver. |
void |
sendObject(java.lang.Object object)
Send an object to the robotserver. |
void |
shutdownSuccessful()
Indicate that shutdown worked. |
void |
waitForReply()
Wait for reply. |
| Methods inherited from class raar.agent.RAAgent |
|---|
canBeEdited, connect, createGVectorObject, disconnect, dump, getActor, getActorNames, getColor, getConnections, getName, getNormalProcesses, getOtherProcesses, getProcess, getProcesses, getWorld, isEditable, notifyAddedToWorld, notifyAddedToWorld, reset, setName, toString |
| Methods inherited from class raar.world.RAWorldObjectMovable |
|---|
resetPR, setPR |
| Methods inherited from class raar.world.RAWorldObject |
|---|
emitsLight, getClassName, isFixed, isLight, isMassive, isMovable, isStatic, moveBy |
| Methods inherited from class vectorimage.VectorObject |
|---|
contains, getBounds, getPosition, getRotation, getType, isFilled, setBounds, setPosition, setRotation |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public RAExternalAgent(RAExternalSensor[] sensorConfig)
throws RAException
RAException
public RAExternalAgent(RAExternalSensor[] sensorConfig,
boolean createActors)
throws RAException
RAException| Method Detail |
|---|
public void addProcess(RAProcess p)
throws RAException
addProcess in class RAAgentRAException
public void removeProcess(RAProcess p)
throws RAException
removeProcess in class RAAgentRAException
public void replaceProcess(RAProcess p,
RAProcess newP)
throws RAException
replaceProcess in class RAAgentRAException
public void runAgent()
throws RAException
runAgent in class RAAgentRAException
public void runAgent(boolean simulated)
throws RAException
RAException
public void pauseAgent()
throws RAException
RAException
public void connect(java.lang.String hostH,
int portP)
throws RAException
RAExceptionpublic void cancelConnect()
public void disconnect()
throws RAException
RAException
public void sendMessage(java.lang.String message)
throws java.io.IOException
java.io.IOException
public void sendObject(java.lang.Object object)
throws java.io.IOException
java.io.IOException
public void waitForReply()
throws java.io.IOException
java.io.IOExceptionpublic void messageReceived(java.lang.Object msg)
public void shutdownSuccessful()
public boolean canBeSimulated()
canBeSimulated in class RAAgentpublic boolean canBeExternal()
canBeExternal in class RAAgentpublic boolean isConnected()
isConnected in class RAAgentpublic java.lang.String getHost()
public int getPort()
public RADataType getSensorValue(RAExternalSensor sensor)
throws RAException
RAException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||